package cn.wolfcode.crmspringboot.config;

import cn.wolfcode.crmspringboot.web.interceptor.LoginInterceptor;
import cn.wolfcode.crmspringboot.web.interceptor.PermissionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//创建拦截配置类
@Configuration
public class MVCJavaConfig implements WebMvcConfigurer{

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Autowired
    private PermissionInterceptor permissionInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册登录拦截器                                对哪些拦截路径起作用
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                //对哪些资源进行排除
                .excludePathPatterns("/loginUser.do","/login.html","/css/**","/js/**","/common/**","/register.html","/registerZ.do");



        //注册权限拦截器                                对哪些拦截路径起作用
        registry.addInterceptor(permissionInterceptor).addPathPatterns("/**")
                //对哪些资源进行排除
                .excludePathPatterns("/loginUser.do","/login.html","/css/**","/js/**","/common/**","/register.html","/registerZ.do");

    }
}
